home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util4 / 0utils.lha / 0Utils / SRunSX.data < prev    next >
Text File  |  1995-09-05  |  3KB  |  129 lines

  1.  
  2. #ifdef TPLTER
  3.  
  4. SRunSX = {
  5.  
  6.     NoParsing;
  7.  
  8.     SHORT = {{ SRun Script Execute }};
  9.  
  10.     DESCRIPTION = {{
  11.     This is a program very Similar to SRun;
  12.     in fact it is just an extension to SRun.
  13.     Additionally to the functionality SRun shows,
  14.     SRunSX examines its first argument, and if this
  15.     is a quoted scriptfile, it explicitely calls
  16.     "Execute".
  17.     This is a workaround for a bug in Kickstart 2.0-3.1
  18.     Boot Shell, which addes a space to the filename, if
  19.     a Script is enclosed in brackets an not called via
  20.     Execute.
  21.  
  22.      RESULT
  23.     STDOUT: the output of the 'command' execution.
  24.     RC:    returnvalue of SystemTags() or >=10
  25.     }};
  26.  
  27.     NOTES = {{
  28.     SRunSX does currently ignore ReadArgs, this is due
  29.     to a bug(?) in readargs that removes some whitespace
  30.     and quotes from argstring even with /F option
  31.  
  32.     Ok, now its 'slowly' becoming a hack ...
  33.     (and ok cbm shell IS a hack ...)
  34.     }};
  35.  
  36.     EXAMPLES = {{
  37.     > echo >  t:xxx "echo hallo"
  38.     > protect t:xxx +s
  39.     > t:xxx
  40.       hallo
  41.     > "t:xxx" ; beware of the quotes!
  42.       EXECUTE: Can't open t:xxx
  43.       object not found
  44.     > echo >"t:xxx " "echo error - this is the wrong script"
  45.     > "t:xxx" ; beware of the quotes!
  46.       error - this is the wrong script
  47.     > SRunSX "t:xxx"
  48.       hallo
  49.     > SRunSX echo hallo
  50.       hallo
  51.     }};
  52.  
  53.     HISTORY = {{
  54.     20-02-95 b_noll created SRun.*
  55.     21-02-95 b_noll added version/format-prefix/offset
  56.     20-03-95 b_noll added args diagnostics
  57.     09-04-95 b_noll shortened the file: arg Parsing dropped, removed NP_tags
  58.     10-04-95 b_noll copied 2 SRunSX.* Removed #ifdef PARSE added Examine
  59.     }};
  60.  
  61.     includes = {
  62.     "<dos/dostags.h>",
  63.     "<string.h>",
  64.     "<exec/memory.h>"
  65.     };
  66.  
  67.     Template = "/F/A";
  68.     Arguments = {{
  69.     STRPTR command;
  70.     }};
  71.     version = "1.3";
  72.  
  73.     body = {{
  74. //      STRPTR template = FORMATPREFIX FORMAT;
  75.     STRPTR a;
  76.     BOOL sprot = NULL;
  77.  
  78.     a = GetArgStr();
  79.     retval = RETURN_ERROR;
  80.  
  81.     do {
  82.         /* ---- Skip spaces */
  83.         //while ((*a == ' ') || (*a == '\t')) ++a;
  84.  
  85.         /* ---- check for quoted script file */
  86.         //if (*a == '"')
  87.         {
  88.         UBYTE buffer[MAXPATHLEN];
  89.         BPTR lock;
  90.         if (ReadItem (buffer, MAXPATHLEN, NULL) == ITEM_QUOTED)
  91.             if (lock = Lock(buffer, SHARED_LOCK)) {
  92.             struct FileInfoBlock *fib;
  93.             if (fib = AllocDosObject(DOS_FIB, NULL)) {
  94.                 if (Examine (lock, fib))
  95.                 sprot = fib->fib_Protection & FIBF_SCRIPT;
  96.                 FreeDosObject (DOS_FIB, fib);
  97.             } /* if */
  98.             UnLock(lock);
  99.             } /* if */
  100.         } /* if */
  101.  
  102.         if (sprot) {
  103.         STRPTR b;
  104.         if (!(b = AllocVec(strlen(a) + 10, MEMF_CLEAR))) {
  105.             retval = 20;
  106.             break;
  107.         } /* if */
  108.  
  109.         strcpy (b, "Execute ");
  110.         strcpy (b + 8, a);
  111.         a = b;
  112.         } /* if */
  113.  
  114.         retval = SystemTagList (a, NULL);
  115.  
  116.         if (sprot)
  117.         FreeVec (a);
  118.     } while (0);
  119.  
  120.     if (retval == -1) {
  121.         retval = RETURN_ERROR;
  122.     } /* if */
  123.     }};
  124. };
  125.  
  126. #endif
  127.  
  128.  
  129.